<!-- Modal -->
<div class="modal fade " id="addCardTypeModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="box box-info">
            <div class="box-header with-border">
                <h3 class="box-title">信用卡卡种维护</h3>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form class="form-horizontal">
                <div class="box-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">银行名称</label>
                        <div class="col-sm-7">
                            <select id="addCardTypeModel_bankId" style="width: 150px"  class="form-control select2"  >
                            </select>
                            <input id="addCardTypeModel_id" type="hidden">
                        </div>
                    </div>

                    <div class="form-group" id="weightDiv">
                        <label for="inputEmail3" class="col-sm-2 control-label">卡种名称</label>
                        <div class="col-sm-7">
                            <input id="addCardTypeModel_cardType" type="text" style="width: 100%;"  class="form-control"  >

                        </div>
                    </div>
                    <div class="form-group" id="weightDiv">
                        <label for="inputEmail3" class="col-sm-2 control-label">年费</label>
                        <div class="col-sm-7">
                            <input id="addCardTypeModel_fee" type="text" class="form-control" style="width: 100%;" >
                        </div>
                    </div>

                </div>
                <!-- /.box-body -->
                <div class="box-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button id="btnSubmit" type="button" class="btn btn-primary pull-right"
                            onclick="addCardTypeModel_save()">保存
                    </button>
                </div>
                <!-- /.box-footer -->
            </form>
        </div>
    </div>
</div>
<script>
    function addCardTypeModel_init() {

        $("#addCardTypeModel_id").val("");
        $("#addCardTypeModel_bankId").empty();
        $("#addCardTypeModel_cardType").val("");
        $("#addCardTypeModel_fee").val("");
    }
    function addCardTypeModel_setValue(index) {
        var url1 = "/creditcardtype/select/addBank" ;
        if(index === -1) {
            setFormValue(url1,"addCardTypeModel_bankId") ;
        } else {
            var options = $("#creditCardTypeTable").bootstrapTable("getData");
            var row = options[index];
            $("#addCardTypeModel_id").val(row.id);
            $("#addCardTypeModel_cardType").val(row.name);
            $("#addCardTypeModel_fee").val(row.annualFee);

            setFormValue(url1,"addCardTypeModel_bankId",row.bankId) ;
        }
    }


    function addCardTypeModel_save() {
        var data = {
            id: val("addCardTypeModel_id"),
            bankId: val("addCardTypeModel_bankId"),
            name: val( "addCardTypeModel_cardType"),
            annualFee: val("addCardTypeModel_fee")
        };
        var url = "/creditcardtype/save";
        postReq(url, data, function (result) {
            if (result.success) {
                toastr['success']('操作成功', '提示');
                $("#creditCardTypeTable").bootstrapTable("refresh");
                $("#addCardTypeModel").modal("hide");
            } else {
                toastr['error'](result.msg, '提示');
            }
        });
    }
</script>
